package com.adcc.ags.cgw.entity.mq;

import com.adcc.ags.cgw.entity.BaseEntity;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;

/**
 * MQ信息实体
 */
public class MQInfo extends BaseEntity{

    // 主机名
    private String host = Strings.nullToEmpty("");

    // 端口
    private int port = 0;

    // 通道
    private String channel = Strings.nullToEmpty("");

    // 队列管理器
    private String qm = Strings.nullToEmpty("");

    // 状态
    private MQState state = MQState.DISCONNECTED;

    // 更新时间
    private String updateTime = Strings.nullToEmpty("");

    /**
     * 构造函数
     */
    public MQInfo(){

    }

    public String getHost(){
        return host;
    }

    public void setHost(String host){
        this.host = host;
    }

    public int getPort(){
        return port;
    }

    public void setPort(int port){
        this.port = port;
    }

    public String getChannel(){
        return channel;
    }

    public void setChannel(String channel){
        this.channel = channel;
    }

    public String getQm(){
        return qm;
    }

    public void setQm(String qm){
        this.qm = qm;
    }

    public MQState getState(){
        return state;
    }

    public void setState(MQState state){
        this.state = state;
        updateTime = DateTime.now(DateTimeZone.UTC).toString(DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public Optional<BaseEntity> formatJson(String json) throws Exception {
        return null;
    }

    @Override
    public String toJSON() throws JsonProcessingException {
        return null;
    }
}
